Computer systems communicate over networks by establishing and using network connections. When providing secure network connections, one concern is that data may be lost during network transmission, and various techniques are used to ensure that data is not lost in transit. An additional concern is the risk that errors will be introduced in data from transmission over the network. One technique for detecting network transmission errors in data uses what is known as a checksum. The basic technique of a checksum is to take a string of data bytes (or other unit of storage) and add them together, then send this sum with the data stream and have the receiver check the sum using the same method used to create the sum. If the receiver's calculated sum matches the sum in the data stream, then no errors have been introduced during transmission.
For example, the Transmission Control Protocol (TCP) provides basic protection against errors in transmission by including a 16-bit Checksum field in the header of each data packet. In TCP, a standard algorithm is used to calculate the checksum which is slightly different than a conventional checksum algorithm. Instead of computing the checksum over only the actual data fields of the TCP segment, a 12-byte TCP pseudo header is created prior to checksum calculation. This header includes information taken from fields in both the TCP header and the IP datagram into which the TCP segment will be encapsulated. The TCP pseudo header includes a source Internet Protocol (IP) address of the originator (taken from the IP header), destination IP address of the intended recipient (taken from the IP header), a reserved field, a protocol field for specifying the protocol used, and a TCP length field specifying the length of the TCP segment including header and data (body) (which is calculated by the originator). The formed pseudo header is placed in a buffer, followed by the TCP segment, and the checksum is computed over this set of data (pseudo header plus TCP segment). The value of the checksum is placed into the Checksum field of the TCP header, and the pseudo header is discarded, since it is not an actual part of the packet and is not transmitted.
The packet is transmitted over the network, and the receiver performs the same calculation by forming the pseudo header performing the checksum (ignoring the Checksum value in the header field to replicate the original condition). If there is a mismatch between its calculation and the value in the Checksum field, this indicates that an error of some sort occurred, and the packet can then be discarded or the error noted. The checksum thus protects against errors in the TCP segment fields and against incorrect segment delivery (if there is a mismatch in the Source or Destination Address), incorrect protocol, and incorrect segment length.
TCP checksum generation is often performed in hardware to achieve faster performance. Since the TCP checksum field is in the packet header, which is transmitted before the packet data, true “on-the-fly” checksum generation is not provided. The packet data must be stored in transmission data buffers, and once the entire packet is received, the checksum can be generated and placed in the header, and then the packet can then start to be transmitted.
One problem with this packet transmission method is that it requires random access to the data buffers storing the packet, so that the checksum field can be accessed and written to with the determined checksum value. This random access capability to a large output buffer adds expense to the system and is slow and sequential, adding latency to the system. Furthermore, the determination of the checksum value can add processing time to the transmission process, since the checksum value is determined only after the packet is fully stored in the data buffer.
In addition, portions of the packets to be transmitted are often stored in different configurations. For example, the header of a packet might be stored in an area of memory easily retrieved with a descriptor, but the body of the packet may be stored elsewhere in memory. Or the header may be stored with the body. However, there are no existing methods to efficiently combine parts of a packet and handle the different packet storage configurations for checksum determination when transmitting.
Accordingly, what is needed is an apparatus and method for providing a network transmission mechanism that can efficiently process checksums for outgoing packets with minimal access to storage buffers, much-reduced latency, and efficient handling of packet storage configurations. The present invention addresses such a need.